%GLOBAL CWD; %LET CWD = %SUBSTR(%SYSGET(SAS_EXECFILEPATH), 1, %EVAL(%LENGTH(%SYSGET(SAS_EXECFILEPATH)) - %LENGTH(%SYSGET(SAS_EXECFILENAME)) - 1));
%INCLUDE "&CWD\TOOLS.SAS";

/* SET ELI & CLUSTER */
%LET ELI = FL031;
%LET CLUSTER = 01A;

/* IDENTIFYING HANDLE */
%LET COM = &ELI._&CLUSTER.;

/* ITEM-SPECIFIC RIGHT HAND SIDE VARIABLES */
%LET RHS= 
    A2 A3 A97SP B1 B2 B98SP B99SP C2 C3 C99SP D2 D98SP
    E2 E3 F2 G2 G3
    MNAMT MNAMTSQ
    ;

%LET STYR=0201;
%LET FIRSTPER=20&STYR;
%LET LASTPER = 200709;
%LET STDUM=D&STYR;
%LET RHYRS= D0202--D0709;

%LET NSPER = %COUNTMONTHS(&FIRSTPER, &LASTPER);
%LET NVEC = %EVAL(&NSPER + %COUNTWORDS(&RHS));

/* DEFINE ITEM-SPECIFIC PRICE EDITS */
%MACRO EDITS;
    IF FULLSAMP_EFFPR_WOTX>1 THEN DELETE;
    IF .02 LE PRICE LE .60;
    IF BSNS_TYPE_CD NE "";
    IF LNAMT =. THEN DELETE;
    IF LNAMT GE 1;
%MEND;

/* DEFINE ITEM-SPECIFIC DUMMIES */
%MACRO VARS;
    B1=(B="B1"); B2=(B="B2"); B3=(B="B3"); B4=(B="B4"); 
    B5=(B="B5"); B6=(B="B6"); B7=(B="B7"); B8=(B="B8"); 
    B99SP=(B="B99"); 
    D1=(D="D1"); D2=(D="D2"); D3=(D="D3"); D4=(D="D4"); 
    D5=(D="D5"); D6=(D="D6"); D7=(D="D7"); D8=(D="D8"); 
    D99SP=(D="D99"); 
    A97SP=(A="A97"); B98SP=(B="B98"); D98SP=(D="D98"); 
    ARRAY SPECARRAY (*) A C E F G;
    DO COUNT=1 TO 5;
        IF SPECARRAY(DIM(SPECARRAY))="" THEN DELETE;
    END;
%MEND;

LIBNAME IN "&CWD\DATA";
LIBNAME OUT "&CWD\DATA";

FILENAME OUTLOGS "&CWD\OUTPUT\LOGINDEXES.XLS";
FILENAME OUTCONTS "&CWD\OUTPUT\LOGCONTRIBS.XLS";
FILENAME OUTDISCS "&CWD\OUTPUT\DISCOUNTS.XLS";
FILENAME OUTPCTLS "&CWD\OUTPUT\PCTLS.XLS";

%INCLUDE "&CWD\TABLESTOBUILD.SAS";
